function DE=diversity(X,m,number_qujian)
if m<3
    m=3;
elseif m>10
    m=10;
end
if number_qujian<10
    number_qujian=10;
elseif number_qujian>120
    number_qujian=120;
end
redata=zeros(length(X)-m+1,m);
for i=1:length(X)-m+1
    for j=1:m
        redata(i,j)=X(i+j-1);
    end
end
redata_sup=redata.^2;
[number_cos,~]=size(redata);
sumnum=zeros(1,m);cosd=zeros(1,number_cos-1);
for i=1:number_cos-1
    for j=1:m
        sumnum(j)=redata(i,j)*redata(i+1,j);
    end
    cosd(i)=sum(sumnum)/(sqrt(sum(redata_sup(i,:)))*sqrt(sum(redata_sup(i+1,:))));
end
p=zeros(1,number_qujian);
for i=1:number_cos-1
    n=ceil((cosd(i)+1)/(2/number_qujian));
    if n<=0
        n=1;
    elseif n>number_qujian
        n=number_qujian-1;
    end
    p(n)=p(n)+1;
end
p=p./(number_cos-1);
for i=1:number_qujian
    if p(i)==0
    else
        p(i)=p(i)*log(p(i));
    end
end
DE=-1/log(number_qujian)*sum(p);
end

